{template '_header'}

<div class="page-heading">
    <span class='pull-right'>
        {ifp 'shop.dispatch.add'}
        	<a class='btn btn-primary btn-sm' href="{php echo merchUrl('shop/dispatch/add')}"><i class='fa fa-plus'></i> 添加配送方式</a>
        {/if}
    </span>
    <h2>配送方式管理</h2> </div>

<form action="" method="get" class="form-horizontal form-search" role="form">
    <input type="hidden" name="c" value="site" />
    <input type="hidden" name="a" value="entry" />
    <input type="hidden" name="m" value="ewei_shopv2" />
    <input type="hidden" name="do" value="web" />
    <input type="hidden" name="r"  value="shop.dispatch" />
    <div class="page-toolbar row m-b-sm m-t-sm">
        <div class="col-sm-4">

            <div class="input-group-btn">
                <button class="btn btn-default btn-sm"  type="button" data-toggle='refresh'><i class='fa fa-refresh'></i></button>
                {ifp 'shop.dispatch.edit'}
	                <button class="btn btn-default btn-sm" type="button" data-toggle='batch' data-href="{php echo merchUrl('shop/dispatch/enabled',array('enabled'=>1))}"><i class='fa fa-circle'></i> 启用</button>
	                <button class="btn btn-default btn-sm" type="button" data-toggle='batch'  data-href="{php echo merchUrl('shop/dispatch/enabled',array('enabled'=>0))}"><i class='fa fa-circle-o'></i> 禁用</button>
                {/if}
                {ifp 'shop.dispatch.delete'}	
                	<button class="btn btn-default btn-sm" type="button" data-toggle='batch-remove' data-confirm="确认要删除?" data-href="{php echo merchUrl('shop/dispatch/delete')}"><i class='fa fa-trash'></i> 删除</button>
                {/if}
            </div>
        </div>	


        <div class="col-sm-6 pull-right">

            <select name="enabled" class='form-control input-sm select-sm'>
                <option value="" {if $_GPC['enabled'] == ''} selected{/if}>状态</option>
                <option value="1" {if $_GPC['enabled']== '1'} selected{/if}>显示</option>
                <option value="0" {if $_GPC['enabled'] == '0'} selected{/if}>隐藏</option>
            </select>	
            <div class="input-group">				 
                <input type="text" class="input-sm form-control" name='keyword' value="{$_GPC['keyword']}" placeholder="请输入关键词"> <span class="input-group-btn">
                    <button class="btn btn-sm btn-primary" type="submit"> 搜索</button> </span>
            </div>

        </div>
    </div>
</form>

<form action="" method="post">
    {if count($list)>0}
    <table class="table table-hove table-responsive">
        <thead class="navbar-inner">
            <tr>
                <th style="width:25px;"><input type='checkbox' /></th>
                  <th style='width:50px'>顺序</th>
                <th>名称</th>
                <th  style='width:100px;'>计费方式</th>
                <th style='width:80px;'>首重(首件)价格</th>
                <th style='width:80px;'>续重(续件)价格</th>
                <th style='width:60px;'>状态</th>
                <th style='width:60px;'>默认</th>
                <th>操作</th>
            </tr>
        </thead>
        <tbody>
            {loop $list $item}
            <tr>
                <td>
                    <input type='checkbox'   value="{$row['id']}"/>
                </td>
                  <td>
                    {ifp 'shop.dispatch.edit'}
                    	<a href='javascript:;' data-toggle='ajaxEdit' data-href="{php echo merchUrl('shop/dispatch/displayorder',array('id'=>$item['id']))}" >{$item['displayorder']}</a>
                    {else}
                    	{$row['displayorder']} 
                    {/if}
                <td>{$item['dispatchname']}</td>

	                {if $item['calculatetype']==0}
		                <td>按重量计费</td>
		                <td>{$item['firstprice']}</td>
		                <td>{$item['secondprice']}</td>
	                {else}
		                <td>按件计费</td>
		                <td>{$item['firstnumprice']}</td>
		                <td>{$item['secondnumprice']}</td>
	                {/if}

                <td>
                    <span class='label {if $item['enabled']==1}label-success{else}label-default{/if}' 
                          {ifp 'shop.dispatch.edit'}
	                          data-toggle='ajaxSwitch' 
	                          data-switch-value='{$item['enabled']}'
	                          data-switch-value0='0|禁用|label label-default|{php echo merchUrl('shop/dispatch/enabled',array('enabled'=>1,'id'=>$item['id']))}'  
	                          data-switch-value1='1|启用|label label-success|{php echo merchUrl('shop/dispatch/enabled',array('enabled'=>0,'id'=>$item['id']))}'  
                          {/if}>
                          {if $item['enabled']==1}启用{else}禁用{/if}</span>

                    </td>
                    <td>
                        <span class='label {if $item['isdefault']==1}label-success{else}label-default{/if} defaults' 
                              {ifp 'shop.dispatch.edit'}
	                              data-toggle='ajaxSwitch' 
	                              data-switch-value='{$item['isdefault']}'
	                              data-switch-value0='0|否|label label-default defaults|{php echo merchUrl('shop/dispatch/setdefault',array('isdefault'=>1,'id'=>$item['id']))}'  
	                              data-switch-value1='1|是|label label-success defaults|{php echo merchUrl('shop/dispatch/setdefault',array('isdefault'=>0,'id'=>$item['id']))}'  
	                              data-switch-css='.defaults'
	                              data-switch-other = 'true'
                              {/if}>
                              {if $item['isdefault']==1}是{else}否{/if}</span>
                        </td>
                        <td style="text-align:left;">
                            {ifp 'shop.dispatch.view|shop.dispatch.edit'}
                            	<a href="{php echo merchUrl('shop/dispatch/edit', array('id' => $item['id']))}" class="btn btn-default btn-sm" >
                            		<i class='fa fa-edit'></i> {ifp 'shop.dispatch.edit'}修改{else}查看{/if}
                            	</a>
                            {/if}
                            {ifp 'shop.dispatch.delete'}
                            	<a data-toggle='ajaxRemove' href="{php echo merchUrl('shop/dispatch/delete', array('id' => $item['id']))}"class="btn btn-default btn-sm" data-confirm='确认要删除此配送方式吗?'><i class="fa fa-trash"></i> 删除</a>
                            {/if}
                        </td>
                    </tr> 
                    {/loop}
                    <tr>
                        <td colspan='9'>
                            <div class='pagers' style='float:right;'>
                                {$pager}			
                            </div>
                        </td>
                    </tr>
                </tbody>
            </table>

            {else}
            <div class='panel panel-default'>
                <div class='panel-body' style='text-align: center;padding:30px;'>
                    暂时没有任何配送方式!
                </div>
            </div>
            {/if}
        </form>

        {template '_footer'}